/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.uac.dao.vo;

import java.util.Date;

import com.eelpo.cmmp.core.wicket.panel.paging.ISort;
import com.eelpo.cmmp.uac.dao.vo.enumed.Status;
import com.eelpo.common.util.BlankUtils;

/**
 * <pre>
 * 
 * 角色值对象(Value Object)
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class Role implements ISort {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 5724446825951125519L;

	/**
	 * 角色Id
	 */
	private String id;

	/**
	 * 角色名称
	 */
	private String name;

	/**
	 * 角色状态
	 */
	private Status status;

	/**
	 * 添加时间
	 */
	private Date addTime;

	/**
	 * 角色描述信息
	 */
	private String description;

	/**
	 * 排序字段
	 */
	private String sort;

	public Role() {

	}

	public Role(Status status) {
		this.status = status;
	}

	public Role(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public void setSort(String sort, String mode) {
		this.sort = sort.concat(" ").concat(mode);
	}

	@Override
	public boolean equals(Object obj) {
		if (BlankUtils.isBlank(obj) || !(obj instanceof Role))
			return false;

		if (this == obj)
			return true;

		Role role = (Role) obj;

		if (BlankUtils.isBlank(this.id) || BlankUtils.isBlank(role.getId())) {
			return false;
		}

		return this.id.equals(role.getId());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public String toString() {
		return name;
	}
}
